package edu.szte.ovrt.datahandler.xml;

import java.io.StringReader;

import static edu.szte.ovrt.datahandler.test.ModelFactory.*;

import javax.xml.stream.XMLStreamException;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

import edu.szte.ovrt.datahandler.core.DocumentReader;
import edu.szte.ovrt.datahandler.core.DocumentReaderException;
import edu.szte.ovrt.datahandler.model.Document;

public class XMLReaderTest {
	@Test
	public void testReadFullDocument() throws XMLStreamException, DocumentReaderException {
		final DocumentReader reader = new XMLReader(new StringReader(DOCUMENT_FULL_XML));
		final Document document = reader.readDocument();
		assertEquals(createDocumentFull(), document);
	}

	@Test
	public void testReadEmptyDocument() throws XMLStreamException, DocumentReaderException {
		final DocumentReader reader = new XMLReader(new StringReader(DOCUMENT_EMPTY_XML));
		final Document document = reader.readDocument();
		assertEquals(createDocumentEmpty(), document);
	}

	@Test
	public void testReadOneSectionDocument() throws XMLStreamException, DocumentReaderException {
		final DocumentReader reader = new XMLReader(new StringReader(DOCUMENT_ONE_SECTION_XML));
		final Document document = reader.readDocument();
		assertEquals(createDocumentWithOneSection(), document);
	}
}
